package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class TimesInterestEarnedRatio extends Equation {
	
	private double income_before_taxes;
	private double interest_charges;
	
	public TimesInterestEarnedRatio(){}
	
	public TimesInterestEarnedRatio( double incomeBeforeTaxes, double interestCharges )
	{
		this.income_before_taxes = incomeBeforeTaxes;
		this.interest_charges = interestCharges;
		value = ( income_before_taxes / interest_charges);
	}
	
	

	@Override
	public String getEquationName() {
		return EquationNames.TIMES_INTEREST_EARNED_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add(FieldList.INCOME_BEFORE_INCOME_TAXES_AND_INTEREST);
		requiredFields.add(FieldList.INTEREST_CHARGES);
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		income_before_taxes = values[0];
		interest_charges = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + income_before_taxes +" / " +interest_charges +" ) = " + value;
	}

	@Override
	public void solve() {
		value = ( income_before_taxes / interest_charges );
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.INCOME_BEFORE_INCOME_TAXES_AND_INTEREST +" / " +FieldList.INTEREST_CHARGES +" )";
	}

}
